package com.pti.fsc.api.service.${entityName?lower_case}.accessor;

import com.pti.fsc.common.AppContextUtil;
import com.pti.util.exception.AppException;
import com.pti.util.locator.ResourceInfo;
import com.pti.util.locator.ResourceLocator;
import com.pti.util.log.Logger;

public class ${entityName}ServiceAccessor {

	private static Logger logger = Logger.getInstance(${entityName}ServiceAccessor.class.getName());
	
	public static final String SERVICE_NAME = "API-EJB/" + ${entityName}Service.class.getName();
	
	private static ResourceInfo serviceInfo = null;
	
	private ${entityName}Service service = null;
	
	static {
		try {
			serviceInfo = ResourceLocator.getInstance().getEjbInfo(SERVICE_NAME);
		} catch (Exception e) {
			logger.error("Service " + SERVICE_NAME + " can not be located.", e);
		}
	}

	public ${entityName}ServiceAccessor() {
		try {
			if (serviceInfo != null){
				service = (${entityName}Service) ResourceLocator.getInstance().lookup(serviceInfo);
			}
		} catch (Exception e) {
			logger.error("creating service error", e);
		}
	}
	
}
